define(function(require, exports, module) {
    var ALL = require("../../common/all"),
        CONFIG = ALL.CONFIG,
        METHOD = ALL.METHOD,
        Dialog = ALL.Dialog,
        Init = ALL.Init;

    var _Dialog = new Dialog({
        title : "提示",
        content : "<p>确定是否提交？</p>",
        text4Btn: ["确定", "取消"],
        class4Btn: ["", "line"]
    });


    var _vm = Init.initVue({
        data : {
            id: null,
            check: {},
            res : {
                col_id : '',
                no : '',
                name : '',
                r_fee: ''
            }
        },
        methods: {
            submit : function() {
                var url;

                this.check.$valid();
                flag = this.check.flag;

                if (!flag) { return; }

                if (!_vm.id) {
                    url = "fee/add";
                } else {
                    url = "fee/update";
                }

                _Dialog.showUI(function(i) {
                    if (i == 0) {
                        METHOD.loading.show();
                        METHOD.ajax(url,{data: JSON.stringify(_vm.res) },{type : 'post'}).done(function(){
                            METHOD.alert("操作成功").done(function(){
                                window.location.href = "../trade/fee.html";
                            });
                            METHOD.loading.hide();
                        }).fail(function(){
                            METHOD.loading.hide();
                        });
                    }
                    this.hideUI();
                });
            },
            getInfoCallback : function(o) {
                if (o) {
                    this.user_id = o.id;
                    this.res.name = o.name;
                } else {
                    this.user_id = "";
                    this.res.name = "";
                }
            }
        }
    });

    _vm.id = METHOD.getQueryParms("id") || null;

    if (_vm.id) {
        METHOD.loading.show();
        METHOD.ajax("fee/detail",{id: _vm.id}).done(function(json){
            METHOD.loading.hide();
            _vm.res = json.data;
        }).fail(function(){
            METHOD.loading.hide();
        })
    }

});

